home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0626 / base64.txt next >
Text File  |  1997-04-06  |  22KB  |  538 lines

  1. Documentation for the Base64 Utilities
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. Contents:
  5. ~~~~~~~~~
  6.  
  7. 1. General information regarding the programs
  8. 2. About ENCODE64.EXE 
  9.   + Examples
  10.   + Forming header string(s)
  11. 3. About DECODE64.EXE    
  12.   + Examples / Multi-part decoding help
  13. 4. About UNIX2DOS.COM
  14. 5. Technical information regarding BASE-64 encoding
  15. 6. Disclaimer, Distribution, About the Author, etc. 
  16. 7. Registration Information
  17. 8. Revision Notes
  18.  
  19. The only requirement for any of these programs is DOS for ENCODE64
  20. and DECODE64, and Windows 3.1 or above for SHELL2 (it will also work
  21. on Windows '95).
  22.  
  23. For information on SHELL2.EXE, refer to SHELL2.TXT.
  24.  
  25. Find other good programs like this one at my home page:
  26.      
  27.    http://www.geocities.com/SiliconValley/Park/3056/
  28.  
  29. Support Shareware: Register!
  30.  
  31.  
  32. 1. General:
  33. ~~~~~~~~~~~
  34.   These DOS programs have built-in error checking to make sure the files
  35. are processed correctly. However, if there are unexplained errors while
  36. processing, the program will give a "Runtime Error" message. Check in
  37. this documentation for information regarding possible errors. Most errors
  38. will likely be caused by the DECODE64 program, because of text-processing
  39. problems. If all else fails, refer to the section on DECODE64 and see
  40. how the program works! If you think a certain problem may be a bug in 
  41. the program, please e-mail me. My e-mail address is at the bottom of 
  42. this file.
  43.  
  44.   NOTE: DECODE64 will ONLY decode files with a CR/LF at the end of every
  45. line, so it will not decode UNIX text files. A (freeware) utility I wrote 
  46. was included with these programs, called UNIX2DOS. See the section on 
  47. UNIX2DOS.EXE for information on how to use it.
  48.   
  49.   REGARDING E-MAIL: Internet mail programs will almost definitely not 
  50. recognize encoded files over e-mail when encoded using ENCODE64. This 
  51. is because information is added to the header and body of sent e-mails 
  52. when files are included with them. It is impossible to mimic this with 
  53. these programs. Whoever receives a Base64 encoded file encoded using 
  54. ENCODE64 may need a utility similar to DECODE64 to be able to decode 
  55. it. (This is especially true when using multiple-part encoding & decoding.)
  56.  
  57.  
  58. 2. About ENCODE64.EXE:
  59. ~~~~~~~~~~~~~~~~~~~~~~
  60.   This program takes any file (binary or otherwise) and converts it 
  61. into a format transmittable over the Internet. (See technical information 
  62. below.) The command line for this program is:
  63.  
  64. ENCODE64 <input filename> [output filename] [/M<number>] [/O] [/P]
  65.          [/B<boundary>] [/H<header>]
  66.  
  67. Items in <> are necessary, in [] are optional.
  68.  
  69. Where <filename> is any file. [Output filename] is optional, but if you
  70. do give it, ENCODE64 will attempt to use that file name instead of the
  71. generic ".64" filename. 
  72.  
  73. /B<boundary> --> Make your own "boundary" string inside of the encoded 
  74. files. This is more advanced and will probably not need to be used unless 
  75. you're using ENCODE64.EXE with an e-mail program.
  76.  
  77. /H<header> --> Lets you form your own header. This is an advanced 
  78. option; see the end of this section for more information.
  79.  
  80. /O --> When you use this option, the program will AUTOMATICALLY attempt 
  81. to overwrite any files it needs to, without having a (Y/N) prompt. Use 
  82. this carefully.
  83.  
  84. /M --> Tell ENCODE64 to do a multiple-file output. A number should 
  85. immediately follow, telling ENCODE64 how many kilobytes (KB) of 
  86. data should be put into each file. 1 kilobyte is slightly less than 
  87. 20 lines of data. The program will tell you if the number of kilobytes you 
  88. specified is too out of range for the particular file you are encoding. 
  89. The maximum number of files ENCODE64 will output to is 99 (for filename 
  90. reasons). Use the Base64 Windows Shell program for easier multi-part
  91. encoding.
  92.  
  93. /P --> Turn on a percentage meter which tells how far through ENCODE64 
  94. is. For single files, it will show how far it is so far. For multiple 
  95. files, it will show how far through it is for the particular file it 
  96. is working on. (The last file it creates may not reach 100%)
  97.  
  98. * Examples: *
  99. ~~~~~~~~~~~~~
  100.  
  101. C:\>ENCODE64 PROGRAM.ZIP
  102.  
  103. After executing this, ENCODE64 will create a file called "PROGRAM.64" in
  104. the current directory. If a file with that name was already found, it will
  105. say so and will not overwrite it (it must be moved or deleted before
  106. ENCODE64 will create the file, just to make sure that no data is lost).
  107.  
  108. C:\>ENCODE64 PROGRAM.ZIP PROG.TXT
  109.  
  110. ENCODE64 will attempt to make a file called PROG.TXT instead of the
  111. generic PROGRAM.64. It will ask you if you wish to overwrite it if
  112. it already exists.
  113.  
  114. C:\>ENCODE64 PROGRAM.ZIP PROG.TXT /M20 /O /P
  115.  
  116. ENCODE64 will attempt to make multiple files until the end of PROGRAM.ZIP
  117. is reached. It will start with PROG01.TXT, put 20 kilobytes of encoded data
  118. in it (approx. 400 lines of data), then move on to PROG02.TXT. If it 
  119. encountered PROG01.TXT already, it will automatically overwrite it because 
  120. the "/O" option was put on the command line. It will also have a percentage
  121. meter which will show how far it is through each one of the files it
  122. creates.
  123.  
  124.  
  125. * Forming your own header strings *
  126. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  127.  If you are using ENCODE64 with an e-mail system, you may need to do
  128. this to make other programs recognize files encoded using ENCODE64.EXE.
  129. Since the command line cannot accept <CR/LF> characters (for line breaks),
  130. you will need to use the following special characters:
  131.  
  132. % -- Insert filename.
  133. ^ -- Insert CR/LF.
  134. # -- Insert space.
  135.  
  136. This would be a generic header:
  137.  
  138.  -hContent-Disposition:#attachment;#filename="%"
  139.  ^Content-Transfer-Encoding:#BASE64
  140.  ^Content-Type:#application/octet-stream
  141.  
  142. (Note that I split up into three sections what would normally be a
  143. single string on the command line.)
  144.  
  145. If this header string were used, the header that appears at the top
  146. of encoded files would appear like this:
  147.  
  148.  Content-Disposition: attachment; filename="anyfile.zip"
  149.  Content-Transfer-Encoding: BASE64
  150.  Content-Type: application/octet-stream
  151.  
  152.  
  153. 3. About DECODE64.EXE:
  154. ~~~~~~~~~~~~~~~~~~~~~~
  155. This part of the documentation may seem a little complex, but the
  156. only really necessary command-line option is the first: the input file
  157. which contains the encoded data.
  158.  
  159. Command line for this program is:
  160.  
  161. DECODE64 <input file/file mask> [output file] [/M] [/O] [/K] [/L]
  162.  
  163. Items in <> are necessary, in [] are optional.
  164.  
  165. Where <input filename> is any Base64-encoded file.
  166.  
  167. /O --> Tell DECODE64 to automatically erase any files it needs to 
  168. without prompting you. Be careful when using this switch that you
  169. do not overwrite any important files.
  170.     
  171. /K --> Tell DECODE64 to NOT Keep reading through a Base64-
  172. encoded file until all files are decoded out of it. If you want it to
  173. stop scanning the file after the first file is decoded, or if you know
  174. that the encoded file only contains one file to decode, then use this.
  175. It will speed up processing because DECODE64 won't need to keep
  176. searching.
  177.  
  178. [output filename] --> DECODE64 will use this instead of the filename 
  179. it finds inside the Base64-encoded file(s). When using the "/M" option, 
  180. DECODE64 will use the filename it finds in the first Base64-encoded 
  181. file it scans.
  182.  
  183. /M --> Tell the program to accept input from more than one file. If 
  184. you use this, you should use a <filename mask> instead of a single 
  185. <input filename>. The mask should use generic DOS wildcard characters 
  186. such as '*' and '?'. Use the "DIR" command to make sure the files are 
  187. in the correct order before decoding. (See examples below.)
  188.  
  189. /L --> Tell DECODE64 to decode multiple encoded files, one at a time, 
  190. using a <file mask>. This (obviously) does not work with "/M". The 
  191. [output file] option does not work with this. "/K" is automatically 
  192. activated by the program when this switch is used, meaning that only
  193. the first file located in each encoded file will be decoded, and 
  194. decoding will stop in each file as soon as the first file is finished.
  195. (See examples below.)
  196.  
  197. At the top of every multiple-part file created by ENCODE64, it tells what 
  198. part number the current file is, and how many parts there are totally.
  199. This first number can be used to create the correct filename for decoding
  200. multiple-part files, if you receive them in different e-mails. (Otherwise
  201. there may not be a way to tell which file comes first, second, etc.) Note
  202. that DECODE64 is *not* able to read this header automatically, since it
  203. does not know which files are made with which encoder.
  204.  
  205. DECODE64 will automatically right- and left-justify all lines of encoded
  206. data.
  207.  
  208. * Examples: *
  209. ~~~~~~~~~~~~~
  210.  
  211. C:\>DECODE64 PROGRAM.64 PROG.ZIP
  212.  
  213. Running it with this command line will make DECODE64 attempt to
  214. decode PROGRAM.64, and, instead of using the file name it finds in
  215. PROGRAM.64, it will use the filename PROG.ZIP to output to.
  216.  
  217. -
  218. C:\>DECODE64 PROGRAM.64 PROG.ZIP /O
  219.  
  220. If PROG.ZIP already exists, DECODE64 will erase it without prompting.
  221. -
  222.  
  223. C:\>DECODE64 PROG*.64 PROG.ZIP /M /O
  224.  
  225. DECODE64 will use the filename mask "PROG*.64" and use those files to
  226. output to PROG.ZIP. DECODE64 will discard whatever filename it finds
  227. in the PROG*.64 files, and use the name "PROG.ZIP" instead. If PROG.ZIP
  228. already exists, DECODE64 will erase it without prompting. Be careful
  229. when using the /M option -- use "DIR" before running DECODE64 to make
  230. sure your files are in the correct order. Such as:
  231.  
  232. PROG01.64
  233. PROG02.64
  234. PROG03.64
  235.    ...
  236.  
  237. This would be ideal. This is the order that ENCODE64 puts files in.
  238.  
  239. -
  240. C:\>DECODE64 *.64 /L
  241.  
  242. This would decode all files with the ".64" extension, one at a time.
  243. -
  244.  
  245. The ideal format for the BASE 64 file would be one created by the 
  246. ENCODE64 program, or in this format:
  247.  
  248. --==========================
  249. name="test.zip"
  250. <header stuff>
  251. <header stuff>
  252.  
  253. AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPP
  254. QQ==
  255. --==========================
  256.  
  257. Note the blank line between the header and the encoded data, and the
  258. "-" character immediately following the encoded data. This will make
  259. sure the file is created properly.
  260.  
  261. If there is no blank space between the header and the encoded data,
  262. the program will keep reading until it reaches a blank line, causing
  263. errors.
  264.  
  265. If the file ends immediately after the encoded data, DECODE64 will give
  266. an error message ("Possible unexpected end of file"), but will 
  267. nevertheless create the file correctly. It is recommended that there
  268. be a line starting with a dash (-) immediately following the data.
  269.  
  270. About the "Bad Character" error: This error is caused by a character
  271. other than the ones accepted by Base64 being in the encoded data. This
  272. error will not halt the program, but the outputted file may have bad
  273. data in it. If the end of the encoded data was not properly found,
  274. this error could also be caused by DECODE64 attempting to decode 
  275. regular text which may appear after the encoded file segment.
  276.  
  277. Most other errors may be caused by DECODE64 not being able to properly
  278. find the end of the encoded data. For best results, edit the encoded
  279. file so it matches the template shown above.
  280.  
  281.  
  282. 4. About UNIX2DOS.COM:
  283. ~~~~~~~~~~~~~~~~~~~~~~
  284.   I included this program in the archive so that users who have a UNIX
  285. e-mail system can also use the Base64 encoder and decoder. The program
  286. will convert any generic UNIX-type text file to the DOS CR/LF standard.
  287. The command line is simple:
  288.  
  289. UNIX2DOS <input filename>
  290.  
  291. Where <input filename> is the name of any UNIX-type text file. 
  292.  
  293. This program will not harm DOS-type text files if they are processed.
  294.  
  295.  
  296. 5. Technical Information:
  297. ~~~~~~~~~~~~~~~~~~~~~~~~~
  298.   BASE-64 (MIME encoding) converts regular 8-bit encoded files into 
  299. a form which can be readily transmittable via Internet e-mail. It
  300. is impossible to send any 8-bit file over e-mail without this or a
  301. similar process done (such as XX-encoding, UU-encoding, etc).
  302.   The way it encodes is by taking three (8-bit) bytes from the file, 
  303. and converting those 24 bits into 4 sets of 6-bit numbers. Since a 
  304. 6-bit number can never go over 63, it outputs to the BASE-64 file
  305. with these characters:
  306.  
  307. Character:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
  308. Value:    0..............................................................63
  309.  
  310.   Since all files will not have sizes evenly divisible by three, padding
  311. is added with the "=" character at the end of the BASE64-encoded data.
  312.  
  313.   BASE-64 is superior to UU encoding & XX encoding in that it does not 
  314. use any characters that may *not* be readily transmittable via Internet.
  315. Also, for every 45 encoded characters of XX & UU, there is one extra
  316. character as a line checksum (seen as the first character of every
  317. line). Data transmission has become so reliable that checksums are
  318. no longer necessary.
  319.   For more information on MIME encoding, look up RFC 1521. (This and 
  320. other files can be downloaded off my homepage. See the URL at the top
  321. of this document or by running ENCODE64 or DECODE64.)
  322.  
  323.  
  324. 6. Disclaimer, Distribution, About the Author, Etc.
  325. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  326.   DISCLAIMER: I'm not responsible if this messes up your computer in
  327. any way. But how could it? :) 
  328.  
  329.   If you enjoy using this, or use it a lot, please register! Since I
  330. have spent WAY too much of my life updating this program and providing
  331. support to users, I have "upgraded" this from freeware to shareware.
  332. (There are 400+ lines of code in DECODE64 alone!)
  333.  
  334.   If there are any persistent problems with either of the programs which 
  335. you think are bugs, e-mail me. 
  336.  
  337.   These programs can be distributed freely as long as ALL of the original 
  338. files are kept in the same archive, not modified in any way, and no 
  339. other programs can be put into the same archive with these. (See
  340. VENDOR.TXT) If these programs are put on a CD-ROM, FTP site, WWW, BBS, 
  341. etc, I'd appreciate knowing it! Also, none of the programs can be sold.
  342.   
  343.   Thanks go to the few people who have written me and convinced me to 
  344. bring out future versions with revisions and improvements, and to those
  345. who have written just to thank me! :)
  346.  
  347. My e-mail address is: frog@star2.opsys.com
  348. If that doesn't work: d034923c@dc.seflin.org
  349.  
  350. My homepage (great place!): 
  351.          
  352.          http://www.geocities.com/SiliconValley/Park/3056/
  353.  
  354.  
  355. 7. Registration information
  356. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  357.   As you may have noticed, I have not added anything to the program to
  358. cripple it, or any "nags". (Except for a small registration notice at
  359. the beginning of the program. :) I've also been giving out a lot of
  360. technical support to many, many users!
  361.   
  362.   So, if you use this program a lot, please e-mail me for registration
  363. information. (Especially important for companies!)
  364.  
  365.   You can request a registration form by writing to me at the address
  366. below. Registration is just $15^ for the three programs (ENCODE64,
  367. DECODE64, and the always useful SHELL2). Just $5 each + of course, you
  368. get UNIX2DOS for free.
  369.  
  370. My e-mail address is: frog@star2.opsys.com
  371. If that doesn't work: d034923c@dc.seflin.org
  372.  
  373.  
  374. ^ -- A company site license is extra.
  375.  
  376.  
  377. 8. Revision Updates
  378. ~~~~~~~~~~~~~~~~~~~
  379.  These notes tell of features, etc, added to the programs after the
  380.  first release. The programs themselves don't tell their own version 
  381.  number, but if this document was included with your archive, then you 
  382.  have the updated version.
  383.  
  384.  Sorry, no fancy version numbers. Can only make filename eight 
  385.  characters! 
  386.  
  387. --\
  388. #1|--> Basic version. Didn't even support more than one command line
  389. --/     option. :(  After a lot of tracking down, I even found a copy
  390.         of it!
  391.  
  392. --\
  393. #2|--> 1. First update. 
  394. --/   
  395.        2. Support for using the 'name = <filename>' string instead of 
  396.            'name="<filename>"' string. (Used by some encoders.)
  397.          
  398.        3. User can now optionally overwrite files: either the Base64
  399.            files created by ENCODE64 or the files created by DECODE64.
  400.    
  401.        4. Support for some encoders, which, instead of having dashes 
  402.            ("-") immediately following encoded data, will terminate 
  403.            with a blank line. If DECODE64 finds a blank line anywhere  
  404.            in encoded data, it will stop processing.
  405.  
  406. --\
  407. #3|--> Basically re-wrote the entire program.
  408. --/
  409.        1. User can now enter two filenames on the command line, one
  410.            specifying the input file, and one the output file. For
  411.            ENCODE64, you can specify the file name to use instead of
  412.            the generic ".64" file; with DECODE64, you can specify
  413.            which file name to use instead of the one found in the
  414.            header of the file DECODE64 decodes.
  415.            
  416.        2. Fast, Assembler character search routine added to DECODE64.
  417.  
  418.        3. Corrected error of DECODE64: it left one or both files open if
  419.            an error occurred during processing.
  420.  
  421.        4. /O option added to command line. This will force the programs
  422.            to automatically attempt to overwrite any files they create,
  423.            without making a (Y/N) prompt to ask you if you want it 
  424.            overwritten. ***USE CAREFULLY*** (So as to not overwrite 
  425.            important data.)
  426.  
  427.        5. /M option added. For ENCODE64, this will allow the output of
  428.            more than one Base64 file; for DECODE64, this will allow
  429.            the input of more than one Base64 file into one larger file.
  430.            (When using with DECODE64, it requires a filename mask instead
  431.            of an input filename.)
  432.  
  433.        6. Programs themselves have become more helpful -- I've added
  434.            better help and error notices. Just run the programs with
  435.            no command line to see the help.
  436.  
  437.        7. Added more efficient code to both ENCODE64 and DECODE64. Nearly
  438.            doubled the math speed of ENCODE64.
  439.  
  440. --\
  441. #4|--> 1. Included the file utility UNIX2DOS with the archive. It will
  442. --/        convert UNIX text files to DOS format, which is used by 
  443.            ENCODE64 & DECODE64. It will not harm DOS text files if they
  444.            are accidentally processed.
  445.  
  446.        2. Percentage meter added to ENCODE64, activated by the "/P" 
  447.            command-line parameter. For single-file encoding, it will
  448.            tell you how far through it is. For multiple file encoding,
  449.            it will tell how far complete it is on the single file it
  450.            is working on. (The last file it creates may not reach 100%)
  451.  
  452.        3. ENCODE64 tells how many files it will create before it starts
  453.            processing.
  454.  
  455.        4. Added code to ENCODE64 for faster string concatenation. Over
  456.            double the speed of the old routine.
  457.  
  458.        5. ENCODE64 now, instead of using number of lines as the basis
  459.            for multi-part encoding, will use kilobytes instead.
  460.  
  461.        6. SHELL64 program added to archive; Windows program to make
  462.            encoding and decoding files easier, especially for multiple
  463.            files. It is the first version, so there may be some bugs
  464.            to iron out.
  465.  
  466.        7. "Text/plain" in header of encoded files has been changed to
  467.             "application/octet-stream" for compatibility with mail
  468.             programs.
  469.  
  470. --\
  471. #5|--> 1. ENCODE64 has gotten even faster AND smaller. A miracle of
  472. --/        modern programming efficiency. :)
  473.  
  474.        2. DECODE64 can now decode more than one file out of a single
  475.            Base64-encoded file, using the "/K" option.
  476.  
  477.        3. ENCODE64 changed so last boundary marker leaves extra two
  478.            dashes ("--") for more compatibility with MIME. Also, there
  479.            is now an empty line between the last line of encoded data
  480.            and the last boundary marker.
  481.  
  482.        4. Another option added to DECODE64 -- "/L". With this, many
  483.            files can be decoded at once using a <file mask>. Useful 
  484.            for batch files and e-mail programs!
  485.  
  486.        5. DECODE64 will now "intelligently" scan for the filename in
  487.            the header. It will look for anything between two quotes
  488.            and anything coming after the "=" symbol. (Not just for the
  489.            two 'name = ' and 'name="' strings.) It is much more
  490.            compatible with e-mail programs.
  491.  
  492.        6. UNIX2DOS has been re-written entirely in Assembler for more
  493.            speed. Therefore, it doesn't really have that many options,
  494.            and is only safe when used properly. On the other hand,
  495.            it is faster and much smaller!
  496.  
  497. --\
  498. #6|--> 1. UNIX2DOS re-written. VERY fast.
  499. --/        
  500.        2. Support for new Content-Disposition header. Hopefully this
  501.            won't mess up any e-mail programs.
  502.  
  503.        3. You can define your own boundary marker now. Good for using
  504.            ENCODE64 with e-mail systems.
  505.  
  506.        4. 386 Assembler code added for more speed. Still not very fast,
  507.            but what can you expect from Pascal?
  508.  
  509.        5. Headers can be defined on the command line.
  510.  
  511.        6. Small error using ENCODE64 with Shell64 -- the pause after the
  512.            program runs would sometimes mess things up a bit.
  513.  
  514. --\
  515. #7|--> 1. Shell64 reincarnated as Shell2.
  516. --/
  517.        2. 386 code being taken out of version #6. Wasn't worth not letting
  518.            the program be run on 286 and slower computers for such a
  519.            minimal gain in speed.
  520.  
  521.        3. Big bugs in the original Shell64 which are fixed in Shell2.
  522.            Probably more, but I can't find everything!
  523.  
  524.        4. Updated Shell2's faulty PIF files.
  525.  
  526.        5. Fixed bug with ENCODE64's and DECODE64's (undocumented) "/W" 
  527.            command-line option, which is only used by Shell2. I think 
  528.            it's actually a bug with the TP compiler I use, but I fixed
  529.            it by adding Assembler code that does nearly the same thing.
  530.            This bug would cause ENCODE64 and DECODE64, when used with
  531.            SHELL2, to produce an error by Windows which would alert the
  532.            user to re-boot the computer.
  533.  
  534.        6. Bug with using DECODE64 with SHELL2 - Shell2 would put the
  535.            file it decodes into the wrong directory. Fixed!
  536. __________________________________________________________________________
  537. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  538.